IWHERE=$(shell (pwd -P))
CFLAGS+=-Wall -Werror

KERNEL_BIN=caller.ko
USER_BIN=user
OUTPUT=\"${IWHERE}/output\"
EXTRA_CFLAGS=-DUSERFILE=\"/tmp/${USER_BIN}\"

obj-m:=caller.o

all: $(USER_BIN) $(KERNEL_BIN)
	@echo "all done"

caller.ko: caller.c Makefile
	make -C /lib/modules/`uname -r`/source SUBDIRS=`pwd` modules

user: user.c Makefile
	$(CC) $(CFLAGS) -DOUTPUT=${OUTPUT} -o $@ $<
	install -m 764 $@ /tmp/

clean:
	make -C /lib/modules/`uname -r`/source SUBDIRS=`pwd` $@
	rm -f $(USER_BIN) Module.symvers

install:
	insmod ./caller.ko
